<template>
  <div>
    <el-dialog
      title="提示"
      :visible.sync="dialogShow"
      width="30%"
      @open="open"
      :before-close="handleClose">
      <el-form :model="form" ref="pmsattrFrom">

          
           <el-form-item label="属性id" label-width="100px">
             <el-input v-model="form.attr_id"></el-input>
           </el-form-item>
          
           <el-form-item label="属性名" label-width="100px">
             <el-input v-model="form.attr_name"></el-input>
           </el-form-item>
          
           <el-form-item label="是否需要检索[0-不需要，1-需要]" label-width="100px">
             <el-input v-model="form.search_type"></el-input>
           </el-form-item>
          
           <el-form-item label="属性图标" label-width="100px">
             <el-input v-model="form.icon"></el-input>
           </el-form-item>
          
           <el-form-item label="可选值列表[用逗号分隔]" label-width="100px">
             <el-input v-model="form.value_select"></el-input>
           </el-form-item>
          
           <el-form-item label="属性类型[0-销售属性，1-基本属性，2-既是销售属性又是基本属性]" label-width="100px">
             <el-input v-model="form.attr_type"></el-input>
           </el-form-item>
          
           <el-form-item label="启用状态[0 - 禁用，1 - 启用]" label-width="100px">
             <el-input v-model="form.enable"></el-input>
           </el-form-item>
          
           <el-form-item label="所属分类" label-width="100px">
             <el-input v-model="form.catelog_id"></el-input>
           </el-form-item>
          
           <el-form-item label="快速展示【是否展示在介绍上；0-否 1-是】，在sku中仍然可以调整" label-width="100px">
             <el-input v-model="form.show_desc"></el-input>
           </el-form-item>
          
      </el-form>
      <el-row>
        <el-col :span="24" :push="8">
          <el-button @click="$emit('handler','close')">取 消</el-button>
          <el-button type="primary" @click="save">保 存</el-button>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "pmsattr-save",
  props:["dialogShow","pmsattrFrom"],
  data() {
     return {
        form:{
        
            attr_id:0,
        
            attr_name:'',
        
            search_type:0,
        
            icon:'',
        
            value_select:'',
        
            attr_type:0,
        
            enable:0,
        
            catelog_id:0,
        
            show_desc:0,
        
        }
     }
  },
  methods:{
    handleClose(){
      this.form={}
      this.$emit('handler','close')
    },
    save(){
      if (this.form.attr_id!=0 && this.pmsattrFrom.attr_id!=undefined){
        //修改
        this.$emit("handler","update",this.form)
      }else {
        //新增
        this.$emit("handler","save",this.form)
      }
      this.handleClose()
    },
    open(){
      if (this.pmsattrFrom.attr_id!=0 && this.pmsattrFrom.attr_id!=undefined){
        //把新的数据赋值给form
        this.form=this.pmsattrFrom
      }else {
        //新增
        this.form={}
      }
    }
  },
}
</script>

<style lang="less" scoped>

</style>
